package com.guoji.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Slf4j
@Component
public class AutoHandler implements MetaObjectHandler {
    @Override
    public void insertFill( MetaObject metaObject) {
        log.info("插入开始");
        this.setFieldValByName("createTime", new Date(),metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("修改开始");
        this.setFieldValByName("update_time",new Date(),metaObject);
    }
}
